package com.ruoyi.develop.goodsFee.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.develop.goodsFee.domain.GoodsFee;
import com.ruoyi.develop.goodsFee.service.IGoodsFeeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 研发经费Controller
 * @author qh
 * @date 2023-11-10
 */
@RestController
@RequestMapping("/goodsFee/goodsFee")
public class GoodsFeeController extends BaseController {
    @Autowired
    private IGoodsFeeService goodsFeeService;

    /**
     * 查询研发经费列表
     */
    @PreAuthorize("@ss.hasPermi('develop:GoodsFee:query')")
    @GetMapping("/list")
    public TableDataInfo list(GoodsFee entity) {
        startPage();
        List<GoodsFee> list = goodsFeeService.selectList(entity);
        return getDataTable(list);
    }

    /**
     * 导出研发经费列表
     */
    @PreAuthorize("@ss.hasPermi('develop:GoodsFee:export')")
    @Log(title = "研发经费", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GoodsFee entity) {
        List<GoodsFee> list = goodsFeeService.selectList(entity);
        ExcelUtil<GoodsFee> util = new ExcelUtil<GoodsFee>(GoodsFee. class);
        util.exportExcel(response, list, "研发经费数据");
    }

    /**
     * 获取研发经费详细信息
     */
    @PreAuthorize("@ss.hasPermi('develop:GoodsFee:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(goodsFeeService.selectById(id));
    }

    /**
     * 新增研发经费
     */
    @PreAuthorize("@ss.hasPermi('develop:GoodsFee:add')")
    @Log(title = "研发经费", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody GoodsFee entity) {
        return toAjax(goodsFeeService.insert(entity));
    }

    /**
     * 修改研发经费
     */
    @PreAuthorize("@ss.hasPermi('develop:GoodsFee:edit')")
    @Log(title = "研发经费", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody GoodsFee entity) {
        return toAjax(goodsFeeService.update(entity));
    }

    /**
     * 删除研发经费
     */
    @PreAuthorize("@ss.hasPermi('develop:GoodsFee:remove')")
    @Log(title = "研发经费", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(goodsFeeService.deleteByIds(ids));
    }
}
